package edu.gyc.test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class HiCat {
    public static void main(String[] args) {
        jm();
        hy();
    }

    private static void jm() {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        try {
          fis = new FileInputStream("d:/cat.jpg");
     fos = new FileOutputStream("d:/miao.jpg");

            int n=0;
            while (n != -1) {
                n=fis.read();
                fos.write(n^6);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fis.close();
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }

    private static void hy() {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        try {
            fis = new FileInputStream("d:/miao.jpg");
            fos = new FileOutputStream("d:/cat1.jpg");

            int n=0;
            while (n != -1) {
                n=fis.read();
                fos.write(n^6);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fis.close();
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }
}
